﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddProject.aspx.cs" Inherits="WebApplication2.Web.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../css/font.css" rel="stylesheet" />
    <link href="../css/xadmin.css" rel="stylesheet" />
    <script src="../js/jquery-3.2.1.min.js"></script>
    <script src="../lib/layui/layui.js"></script>
    <script src="../js/xadmin.js"></script>
    <script src="../js/xcity.js"></script>
    <script src="../js/cookie.js"></script>
    <script src="../js/public.js"></script>
</head>
<body>
    <div class="x-body">
        <form class="layui-form">
             <div class="layui-form-item">
                <label class="layui-form-label">
                    <span>所属项目：</span>
                </label>
                <div class="layui-form-mid">
                    <span class="content" id="pro_name"></span>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span>PR单编号：</span>
                </label>
                <div class="layui-form-mid">
                    <span class="content" id="pr_id"></span>
                </div>
            </div>

            <%--//合同金额--%>
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red"></span>合同金额
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="C_Budget" required="" lay-verify="number"
                        autocomplete="off" class="layui-input">
                </div>
                 <div class="layui-form-mid layui-word-aux">要么不填该项，要么只填数字</div>
            </div>
            <%--//合同编号--%>
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red"></span>合同编号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="C_ID" required="" lay-verify=""
                        autocomplete="off" class="layui-input">
                </div>
            </div>


            <%--//采购员--%>
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red"></span>采购员
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="shopMan" required="" lay-verify=""
                        autocomplete="off" class="layui-input">
                </div>
            </div>


            <%--//合同签订时间--%>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red"></span>合同签订时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="C_Time" required="" lay-verify=""
                        autocomplete="off" class="layui-input">
                </div>
            </div>
            <script>
                layui.use('laydate', function () {
                    var laydate = layui.laydate;

                    //执行一个laydate实例
                    laydate.render({
                        elem: '#C_Time' //指定元素
                    });
                });

            </script>

            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button class="layui-btn" lay-filter="add" lay-submit="">
                    确定
                </button>
            </div>

            <script>
                layui.use('laydate', function () {
                    var laydate = layui.laydate;

                    //执行一个laydate实例
                    laydate.render({
                        elem: '#inputTime' //指定元素
                    });
                });
            </script>
        </form>
    </div>
    <script>
                  layui.use(['form', 'layer'], function () {
                      $ = layui.jquery;
                      var form = layui.form
                          , layer = layui.layer;

                      $("#pro_name").text(getCookie("name"))
                      $("#pr_id").text(getCookie("pr_id"))
                      //监听提交
                      form.on('submit(add)', function (data) {
                          layer.confirm('你确定添加一个子项目吗', {
                              btn: ['确定', '放弃'] //按钮
                          }, function () {
                              //Ajax上传逻辑
                              //第一个匿名函数是第一个按钮的回调function
                              sumitNew();
                          }, function () {
                              //取消操作，弹出取消，不清除form表单里的信息
                          });
                          return false;
                      });
                  });

                  /**
                  记录操作者
                  连同记录操作者记录一起AJax提交，在后端程序进行处理
                */
                  function record() {
                      var man;
                      var project;
                      var oprateType;
                      var creatTime;
                      var oprate;
                      Console("");
                  }

                  function sumitNew() {
                      var obj_project = new Object();
                      //采购人
                      obj_project.shopman = ($("#shopMan").val());
                      console.log(obj_project.shopman);
                      //合同编号
                      obj_project.c_id = ($("#C_ID").val());
                      console.log(obj_project.c_id);
                      //合同签订时间
                      obj_project.c_time = ($("#C_Time").val());
                      console.log(obj_project.c_time);
                      //项目ID
                      obj_project.project_id = getCookie("id");
                      console.log(obj_project.project_id);
                      //合同预算
                      var imp = ($("#C_Budget").val());
                      if (imp == '') {
                          obj_project.c_budget = 0;
                      } else {
                          obj_project.c_budget = ($("#C_Budget").val());
                      }
                      obj_project.id = getCookie("id");
                      obj_project.pr_id = getCookie("pr_id");
                      myAjax("BudgetHandler.ashx", "updateless", obj_project, false, function (data) {
                          //提示层
                          console.log(data);
                          if (data.Code == 1) {
                              layer.msg('修改成功');
                              console.log(data);
                          } else if (data.Code == 2) {
                              layer.alert('数据库中不存在此单号', {
                                  skin: 'layui-layer-molv' //样式类名
                                  , closeBtn: 0
                                   //动画类型
                              });
                          }

                      }, function () {
                          layer.alert('发生了一些预期之外的错误');
                          console.alert('发生一些意外');
                      });
                  }
    </script>

</body>
</html>
